package cn.lenchu.web.controller;

import cn.lenchu.core.service.StockService;
import cn.lenchu.stock.model.Stock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lenchu
 */
@RestController
@RequestMapping("/api/stock")
public class StockController {

    @Autowired
    private StockService stockService;

    @GetMapping("/search")
    public List<Stock> searchStock(String keyword, String source) {
        return stockService.searchStock(keyword, source);
    }

    @GetMapping("/code")
    public Stock getByCode(String code, String source) {
        return stockService.getByCode(code, source);
    }
}
